package fr.insee.solr.model.param;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.solr.common.params.CommonParams;

public class SolrRequestBuilder {
	private List<SolrRequestParam.Param> params = new ArrayList<>();

	
	
	private SolrRequestBuilder() {
		
	}


	public static SolrRequestBuilder create(){
		SolrRequestBuilder s = new SolrRequestBuilder();
		return s;
	}
	
	
	
	public SolrRequestBuilder addFacetsField(List<SolrFacetParams> paramsFacet){
		for(SolrFacetParams p : paramsFacet){
			if(p.getField() != null && !p.getField().isEmpty()){
				params.addAll(SolrFacetParamsBuilder.buildFacetField(p));
			}
		}
		
		return this;
	}
	
	public SolrRequestBuilder addFilters(Map<String,String> filters){
		for(String field : filters.keySet()){
			params.add(new SolrRequestParam.Param(CommonParams.FQ,field+":"+filters.get(field)));
		}
		
		return this;
	}
	
	
	public SolrRequestBuilder addFilters(String field, String restriction){
		
		return this;
	}
	
	public List<SolrRequestParam.Param> build(){
		return params;
	}
}
